package cn.kgc.spring04.entity;

/**
 * @author: mosin
 * @version: v1.0  2022/12/1
 * 通过该类研究spring容器中bean的生命周期
 */
public class Person {

    private String name;
    private Integer age;


    public Person() {
        System.out.println("person对象被创建");
    }

    public Person(String name, Integer id) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        System.out.println("name的set方法被调用");
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    // person 初始化方法
    public void init() {
        System.out.println("init()被调用");
    }

    // 销毁方法
    public void destroy() {
        System.out.println("destroy()被调用");
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
